package com.rentong.wx.sys.service.impl;

import com.rentong.wx.cust.dao.WxCustUserMapper;
import com.rentong.wx.cust.domain.WxCustUser;
import com.rentong.wx.sys.dao.SysConfChongzhiBstDao;
import com.rentong.wx.sys.domain.SysConfChongzhiBstEntity;
import com.rentong.wx.sys.service.SysConfChongzhiBstService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysConfChongzhiBstServiceImpl implements SysConfChongzhiBstService {

    @Resource
    private SysConfChongzhiBstDao sysConfChongzhiBstDao;

    @Resource
    private WxCustUserMapper wxCustUserMapper;


    @Transactional(rollbackFor = Exception.class)
    @Override
    public List<SysConfChongzhiBstEntity> getBstInfo(SysConfChongzhiBstEntity sysConfChongzhiBstEntity, Long custId){
        List<SysConfChongzhiBstEntity> list = sysConfChongzhiBstDao.getBstInfo(sysConfChongzhiBstEntity);

        WxCustUser wxCustUser = wxCustUserMapper.selectByPrimaryKey(custId);

        //没有免费帮上推次数了
        if (wxCustUser.getHuiyuanNum() == 0) {
            list.remove(0);
        }

        return list;
    }




}